package com.igoal.dto;

import java.io.Serializable;

import com.igoal.entity.City;
import com.igoal.entity.School;
import com.igoal.utils.SynchronizeAttributeWithOther;
import com.igoal.utils.SynchronizeDirection;

public class SchoolDTO extends BaseDTO<School> implements Serializable {

	private static final long serialVersionUID = 651332928341010743L;

	public static final String DATA_STATUS_ADD = "add";
	public static final String DATA_STATUS_REMOVE = "remove";
	public static final String DATA_STATUS_UPDATE = "update";

	private Long id;
	private String name;
	private String mainStudy;
	private String title;
	private String cityName;
	private Long cityId;
	private Integer from;
	private Integer to;
	private String dataStatus = DATA_STATUS_UPDATE;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String schoolName) {
		this.name = schoolName;
	}

	public Integer getFrom() {
		return from;
	}

	public void setFrom(Integer from) {
		this.from = from;
	}

	public Integer getTo() {
		return to;
	}

	public void setTo(Integer to) {
		this.to = to;
	}

	public boolean isUpdated() {
		return DATA_STATUS_UPDATE.equals(this.dataStatus);
	}

	public boolean isRemoved() {
		return DATA_STATUS_REMOVE.equals(this.dataStatus);
	}

	public boolean isAdded() {
		return DATA_STATUS_ADD.equals(this.dataStatus);
	}

	public String getMainStudy() {
		return mainStudy;
	}

	public void setMainStudy(String mainStudy) {
		this.mainStudy = mainStudy;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	
	public Long getCityId() {
		return cityId;
	}

	public void setCityId(Long cityId) {
		this.cityId = cityId;
	}

	@SynchronizeAttributeWithOther(direction=SynchronizeDirection.FROM, value="city")
	public void initCity(Object entity){
		if(entity != null){
			City city = (City) entity;
			cityName = city.getCityName();
			cityId = city.getId();
		}
	}
}
